fixing up typecasting