Minor change to improve d!=0 case