fixed error with new perimeter alg