Rewrite the sm_watcher code