Refactored by replacing lodash with underscore