cleaned up recursion and renamed it to sets