Fixed cast bug