trigger() no-end loop fixed when listener has been removed in the loop