added ai code