changed pagination to local variable