add paginate gem and simplify counting