solved error function