adding code for paging. Not quite working.