cannot break from flag check loop if flags are active since maybe directory at the end