Add specs and refactoring