refactor init script