Refactoring file handler