refactoring and testing in progress