added check for invalid magic in message decode