Fixed paginate functionality