Further refactoring of loading logic