adding d function