Recursive function used to generate combinations