fixing javascript so that it actually executes at page load