fix to remove node after end