+ threading in gradient calculation