some refactoring / improvements