Change onNodeUpdated to first cleanup previous state