This paper investigates whether management teams that fail to exploit regulatory loopholes are vulnerable to replacement. We use the U.S. hospital industry in 1985-96 as a case study. A 1988 change in Medicare rules widened a preexisting loophole in the Medicare payment system, presenting hospitals with an opportunity to increase operating margins by 5 or more percentage points simply by upcoding patients to more lucrative codes. We find that having room to upcode is a statistically and economically significant predictor of whether a hospital replaces its management with a new team of for-profit managers. We also find evidence that hospitals that replace their management subsequently upcode more than a sample of similar hospitals whose management did not change.