refactored some code used for the compression option