Corrected for loops (removed hasOwnProperty() where it was needed). Renamed variables in for loops.