Refactor to use onmessage property instead of addEventListener('message', ...)