Refactoring new function