Fixed if statement to use typeof event !== undefined