improved TSR error function