fixed algorithm for ami violation