added method to clean up the nodes