use takeMVar instead of readMVar in event handler loop