Functions refactoring