updated distance partitioning, simpler now