refractored parser