Added flag based control flow