speed optimalization of removing nodes