Change withTraits to a object function