hand coded pagination