fixed a bug in AI. also improved it a little