added mechanism for flanck detection