Changed the onload script logic