Added AI logic