Uniformly use the error function with an exit code
Explicit /usr/bin/which with additional error message
Remove redundant code