completed refactor