fix bugs for calculating page and per_page