fix script loop