ami loop fix