Refactor togglenode command