updated logic for remove Node