error when for loop iterates Empty