Implemented AI functionality