Fixed the problem with not counting and double counting verticies