deleteNode function corrected