first part of refactor