refactor flags