fixed flag handling