flags refactoring