handled the nil value case for search