for to for-each

Converted some loops from for to the for-each type supported in Java