first refactor pass