Add some logic around the file rename to stop errors