added pagination to templates