functions refactor vol. 2