Looks inefficient. Is there a better way to do this with a vector?