fix bug with flags not disappearing properly