First version of grad_check