fixed flag's bug