rename function and tidyup
refactoring