minior refactor and add spec