refactor: use a for-loop instead of while in outer-loop of compress.