bug fix for last_page() function