Fixed events so that it works both on chrome and firefox.