faster solution for #1762