Scanning sequence as function of previous logic expression