some refactoring & new variables