added pagination and search implementation
optimised the code.