Refactor setting the flag