add gradients to states