added refactoring function