implemented AI toggle function