how about `for (var i = 0; i < items.length - 1; i++)` for simplicity? Then line 133 and line 134 could be removed.