refactor/rewrite