Refactoring ugly if else in find_rule().
Typo fixed.
Typo fixed.