Fixed a bug introduced by refactoring
Refactor contact filter code