the middle bugfixs for flag operation