corrected the gradients