vec helper function, replace function