factor out common type functions