fix span-error function