remove null values and empty arrays before checking is last in array