refactoring loader logic