refactored gradients