added maxerr option