Refactor predeploy script