improved plane filling to handle more cases