reduced some code using partial application with ecma5 bind function