added row and column swaping