code for gradients