Moved filenames loop into self executing function and changed preview set to single command