Since this function refers to `this`, can the whole thing be moved into the `extend` call? It's odd to see a function refer to `this` outside the definition of a class/object.