refactored compression