little optimization in AI.java