added support for precomputed permutations