Added typecasting to prevent duplicate key errors.