Use the end variable instead of limit (#2142)