Ensure code runs within the onLoad function