Remove useless codes from funcgrad()