Updated the hide method to detect whether or not the event is defined

Fix for issue #1