modifying d function