refactor code and specs