add window onload checking