simplified code using underscore