properly keep track of visited nodes in instance generation
keep track of the already visited targets