Fix the infinite recursion happening when called more than once in same program