updated compute grad