added pagination functionality