Fix this code so that it doesn't try to iterate through a std::vector