#28 some refactoring