last part of refactor