Added tar in function, reduced code