cherry picked from commit fa30a5676028f1240dfd979067fd5110814d055d and resolved merge conflict