Fix getting of total count when paginate.