Refine prefix matching condition to consider mode changes as different.