fixing iteration bug and using _.forOwn()
clean up formatting