fixed wrong flag check