Refactoring finding files to upload

I found some time to refactor it. Perhaps you can use it as a base for more refactoring.