new functions and refactoring