Fixed the type of a iterator variable to fit the type of the upper boundary.