onmessage in correct scope