pattern detection (WIP); single and alt_single detection finished