'which' is an external tool, 'type' is a shell builtin. Using the latter shaves off a bit of latency. Also use the already open stderr file descriptor for redirection.