Fixed bugs on paginate