AI logic partly added