refactor pagination for traditional mvc pattern