refactor and ut