partial refactor