Changed vector iterator to get a reference of the vector rather than copy it