Fix variable lifetime