dominoes, permutation and isloop functions finished