fix bug in total_pages