Nonfactorizable contributions to hadronic decays of D mesons