New functions and refactoring