reorganized some code to put all file movements in one place