minor reorg of helper funcs