refactoring node removal
extracted updateNodes()