code refactor with underscore.js