Fixed AI. Working copy