apply_deriv sort of works