Problem setting global variables with random number