change pages from array to hash to simplify page lookup logic