refactor for flags