fix minor bug when setting flag