Function flipDiagonal