Restructure game,js