refactor, add tests
refactor 2nd method