Refactored init script