Modified to run script on page load