First implementation, convert to array, recursion