improve archive function