refactor and test.
testing.