refactoring out _.isUndefined and _.each, using native