Apply improvement proposed in #2142