included commits from original, restructured bash script