factoring duplication out of argn functions