how to revise arraylist during iteration