Using dynamic vectors instead of realloc