Implemented transposition replacement alg.