added a retention parameter to manage how many archives to keep