fixing greedy matching garbage