Updated bash script according to shellcheck feedback