function randomPick: added var to internal variable definitions