first refactor and tests 1/5 complete