refactoring of functions