Refactor code and set page title on load.