quick comment; the `for` statement creates the local variables used so the `local k,v` is not necessary, the same with second set of locals you create.