some refactoring plus some updates