add pry and refactor some sorting and pagination methods