Moved archive fetching to function