refactored code, bag with game ending