refactor loader and add some logging