backport https://github.com/cms-sw/cmssw/pull/6535

backport https://github.com/cms-sw/cmssw/pull/6535