more flexible impl of is<>