working on minimal cost parse