back port #6305 to CMSSW_7_1_X