refactored file loading