Added recursion and recursing backtracing