refactor the init script