Better logic for finding pages