updated with paging and testing a bug