added pagination to template