changed checking of flags