more refactoring, all specs passing