updated parsing alg