fixed bugs in ai