corrected iteration through list of elements