Why would you use typecasting for a comparison here? Wouldn't a `typeof` check be more elegant?