The old construction method can be quadratic for some inputs. This approach guarantees a reasonable performance.