second attempt at fixing pagination start/end calculation