added target_param option to checkgrad(), removed unused function parameter