changed the placement of the loops made j go before i