Also these declarations of variables outside of this for loop can make it really difficult to read the code. When I get to this for loop, you assign j to something. Considering j is only in this for loop, so why not def it in there?
A side note, is j really that nice of a variable name? What function does j have?
Lastly, if possible, I'd make the for loop into a more "groovy"ish for loop. That's up to your discretion but it may make your code more readable.