Modified the error function