handle different types of message