refactor watcher and matching