A replacement for #2566

#2566