#7 some refactoring