Fix error: Serialization of Closure is not allowed.