refactored file loader