fix D loop condition