added .when() event
added .when() event + fixed .emit() gotcha