A federal judge has thrown out a lawsuit alleging that the U.S. Securities and Exchange Commission is liable to investors for failing to detect Bernard Madoff’s $50 billion Ponzi scheme.

The judge ruled on Tuesday that the agency acted within its discretion.