On approximating the error function