added circular dependancy detection