finalizing gradients