updated to deal with minimal segments and new rontines for drawing paths