cleaning up page load logic