performance improvement version 2,cutting down paginate count queries