Fix cast to avoid "address of temporary" error