fixed a bug in the paving algo