Klass-like extend function