fix EventMachine function call sequence