some refactoring and method cleanup