modified triangulation, added some tests