Use a factory function to extend objects