updated example, fixed event calling bug