refactor, bug fix, unit test