Fixed and simplified code flow for getpageviews function in pageviewqueries.inc file