better AI algorithm and text view