Fourth commit

Adjusted loops to behave correctly