Fixed reference iteration issue