Refactor tar gz to reuse function.