Fix bug in page load script