added wait for window.onload