Apply extract method refactoring
Move function
Remove unused function