doesn't compile, but sketch of gradient done