handling d < 0