refactor to support offline compressing