updated ai code... preliminary work