Better logic for flags settings