Fix flag checking