some refactoring and renaming of variables/methods