added recognition of board permutations - huge optimization