implemented gradients