check for nil before begin ranging