changed ranks from row-wise to column-wise