adding better exception handling on lexical casts