refactoring and adding specs