Added undefined checking for eventFired