Refactor activate script