fix wrong tolerance calculation