Making script work, almost