nl in errorfunc was wrong way round