factored out inheritance into a function