handle different types of messages