Move variable declaration closer to usage