added a test, refactored some loops with lodash