finished initial refactor