fixing one off error in iterator