code refactored and loop added to play several games