fixed mistakes from updating d_grep function