episode refactor