convert handle check into assert