added checking for recursive definitions