Fix undefined issue with empty strings in array