Bugfix onMessage() function