Factoring out archive helper function