Make better pattern matching when a message struct is needed