Refactor watch code