refactor Circuit