refactored to accommodate different page heads