Refactoring global load event function.