improved :: cast to accept more types of expressions