pivot refactor