fix flags handling