fix bug iterating a list