modelled after https://chromium-review.googlesource.com/c/chromium/src/+/1096475 and https://chromium-review.googlesource.com/c/chromium/src/+/1096475