refactor check_types