cherry-picked commit 30819cc377b9b21bd5c2945fbcbcb3bb7451ff0b