end game refactoring cont