fix a cast bug