base code for refactoring