refactor init procedure