fix pagination issue (undeclared variables)