Also use <code>i !== -1</code> instead of <code>i &gt;= 0</code>