diff --git a/src/shell/pipe_exec/mod.rs b/src/shell/pipe_exec/mod.rs
index fb50b3068dcf5489a79ebb3793d9efce70f760fe..2f9de2c877558edea2057e5d47794e227a63e182 100644
--- a/src/shell/pipe_exec/mod.rs
+++ b/src/shell/pipe_exec/mod.rs
@@ -275,12 +275,12 @@ impl<'a> PipelineExecution for Shell<'a> {
                 } else if Path::new(&job.args[0]).is_dir() {
                     eprintln!("ion: cannot execute directory as command");
                     return Err(FAILURE);
-                } else if self.functions.contains_key::<str>(job.command.as_ref()) {
-                    RefinedJob::function(job.command, job.args.drain().collect())
-                } else if self.builtins.contains_key::<str>(job.command.as_ref()) {
-                    RefinedJob::builtin(job.command, job.args.drain().collect())
+                } else if self.functions.contains_key::<str>(job.args[0].as_ref()) {
+                    RefinedJob::function(job.args[0].clone().into(), job.args.drain().collect())
+                } else if self.builtins.contains_key::<str>(job.args[0].as_ref()) {
+                    RefinedJob::builtin(job.args[0].clone().into(), job.args.drain().collect())
                 } else {
-                    let mut command = Command::new(job.command);
+                    let mut command = Command::new(job.args[0].clone());
                     for arg in job.args.drain().skip(1) {
                         command.arg(arg);
                     }