egg refactor