This piece of code could use some comments about what it's doing. The j's `for` loop followed by j's usage seems like code smell at the very first glimpse.