fix type cast bug