Refactoring the code: avoid using class variables.