Changed iterator to make thread safe