fixed ravel to iterate over rows and transpose