refactoring around type check functions