added final deleteNode condition