refactoring file adding out of main controller