Refactoring: simplify variable computation