itemsPerPage filter sometimes gets a string

Which breaks the calculation of the end variable as the + sign then concatenates the string instead of adding as a number.