restructuring message parsing