modify the ld_wf function, change d[] to d[][]
return result and d