refactoring of the watch code