diff --git a/src/parts/trapezoids.jl b/src/parts/trapezoids.jl
index ef33bbcefcb2a5fdad3532cf92dc4d7b27370ba4..8a7eebb8b618e93a0ee1e1a5bfa75ccdd0bab5e3 100644
--- a/src/parts/trapezoids.jl
+++ b/src/parts/trapezoids.jl
@@ -74,7 +74,7 @@ function (::Type{Trapezoid})(; orientation=nothing, rise_time=nothing, flat_time
             get_free_variable.(slew_rate),
             group
         )
-        add_cost_function!(-sum(abs(res.slew_rate)))
+        add_cost_function!(-sum(abs.(res.slew_rate)))
     else
         res = Trapezoid1D(
             get_free_variable(rise_time),