implemented message handling