Updated parsing algorithm