complete final refactor