final refactor with updates