'which' command implementation