Added typecasting total_pages to int instead of float when recalculating