adding NULL detection