refactory shell script for finding code base path