fixed the a trivial bug for casting exception