refactor to allow periodic deletion of all but 5 latest files