Small changes

if you set j to i+1 you don't have to check if i == j