add pagination,refactor