Changed for loops to enhanced for loops
Removed useless variables and if statements