bugfix and improve AI