Fixed issue with a transitive query, working on output statements