modifies query to return page and total pages info