functions refactoring by Giux
merge