Adapted to #commitcomment-4925463