first round of refactor and simplify