Fix issue with empty elements in array