added function to check message type.