fixed bug in event handler