refactoring + while loop
moving files