switched to use 'type -p' everywhere instead of which