add pagination and some functions