Nicely streamlined a function.
Should fix the `sh` errors.