refactor bash scripts