fixed compute gradient