implemented for loops, added TODOs, and cleaned up code