Added safe cast.