refactoring tar generation