refactoting (functions)