Fixed error in inner loop
Fixed loop indentation.