Refactor flag matching method by replacing it with a for loop