fiexed error changed for loop from int i to int j