continue foreach refactoring