added error handling for missing pages