Fixed problem with gradients