Changed the iterator i to be of type size_t instead of int