Changed from document ready to window load