repair a bug when compacting