Simple refactoring of functions