corrected free space algorithm