enhance flag check