use which to check if whence is available before searching for whence with whence, fix #2207