More accurate switching on types