pull the definition outside the if/else. possibly use ternary to initialize