Re-factored code into underscore library