removed the inner for loop