catching InvalidCastException