Added event handling for Firefox compatibility