restructure, fixed message parsing in