Refactoring removing unused variables