fixed off by one on range query with pagenation