diff --git a/src/variables.jl b/src/variables.jl
index b8d9b85fe448f4404413a9ae9788832a16f33da9..3e7cac0d8f3ffb38a60af723373265676e06549b 100644
--- a/src/variables.jl
+++ b/src/variables.jl
@@ -465,10 +465,13 @@ which will generally only be optimised after any user-defined cost functions (wh
 
 Any sequence will also have a `level=3` cost function, which minimises the total sequence duration.
 """
-function add_cost_function!(func, level=2)
+function add_cost_function!(func::AbstractJuMPScalar, level=2)
     push!(GLOBAL_MODEL[][2], (Float64(level), func))
 end
 
+add_cost_function!(func::Number, level=2) = nothing
+
+
 """
     set_simple_constraints!(block, kwargs)