Code refactoring and renamed some of the bash function