refactor loading mechanism