implemented a the onMessage method