Fixed for bug(i instead of j)