Gradient 'algorithm' improved