got rid of useless ifelse statements. Trying to fix the dimension problem by investigating the correctness of transpositions generation.