refactor pagination to not insert into page