common code for games