recursivly exploring all possible solutions