added class_gradients function