Refactor setup script