refactor of code and testing in progress