Updated computeGrad with -advangle option