removes un-needed nodes