refactorize bash run script