cherry-picking alexeypegov:61054d41ef5fea7a8e9956428a01369f922a1dbf