Updated switch_type method with correct types