Recursive program now working