refactored file handler with config