fixed duplicate d_grep function