fixing iteration bug, using _.forOwn(), cleaning up formatting

fixing iteration bug, using _.forOwn(), cleaning up formatting