fixed a bug in recognition logic