Software Design/Reduce variable's scope