fix trying to iterate over empty array