Properly write global event handlers