some refactoring and specs