Refactoring - funcionality extraction to standalone functions,better naming