add greddy and non greddy matching method