Fixed syntax errrors and for loop