refactor pagination and fix for popular page