Updated to work on other types of pages