Better pattern detection