refactoring functions

pull request test