Revised Message parsing algorithm