refactor to make pagination more possible.