Fixed indexing error for edge case conditions for j and k