use pattern matching to deconstruct messages in receive method