condensed code for slice fns