fixed loop event handler issue