The cy pres doctrine is a legal principle that allows a court to modify the terms of a charitable trust or other legal arrangement when it becomes impossible or impractical to fulfill the original intent of the creator. This doctrine is often applied in class action lawsuits to ensure that funds intended for a specific purpose are used in a way that closely aligns with that purpose, even if the original goals cannot be achieved exactly. It serves to promote fairness and efficacy in the distribution of funds in situations where the initial plan fails.