added pagination into database