Updated with loop switching. Prints out all possibilities.