changed type of j from int to size_t. clarified a comment.