added modified version of Mark's fastDerivativeCheck