refactored with lodash