Gradient check added