added tracing to message loop