I would imagine that’s the best solution. make sure you validate the gradient like in @aseyboldt’s reply.