Adding check if permutations is empty