fixed bug: closure in events loop