Refactor compression script so it's reusable