Improved logic.
Improved formatting of new file name.