refactor loading and init