changed control flow to use 'command -v' instead of 'which'