added braces for loops
minor whitespace removal
minor bracing of loops and ifs
minor formating