complete impl of game