Clean javascript functional programming update