adding pagination cotrols and error handling