added a working refactoring