Method to predict drug stability could lead to more effective medicines