First implementation, recursion