add spec & refactoring