forgot to initialize totvert variable prior to building a kdtree