changed window lonload logic