Fix bug about setting event handler