refactor pagination to templatetags