refactor and tests green