beginning of refactor