added pagination and sort functionalities.