algorithm change

in lines 18 to 26. removed the 'j' loop