refactor: improve style and add spec