refactor init process