fixes #12 : and some refactoring
small refactoring