I think there might be a better place for this filename-building code, but I'm not sure where exactly. I think at the least it should be its own method.