Traditional method optimization

This small change in the code will result in a significant improvement, specially as the size of the array grows large.