This will have to be split up somehow, since you'll need to 1) determine intervals, 2) acquire a lock and get a version number, 3) actually make the segments