updated gradients and stage