improvement of AIS routine