slightly better (but more complex) checking of used types