refactoring to expose loading as a function call