Fixing typecasting error