branched to optim, straight lines detected
option for two tolerances built