updating compute grad