Fix bug with random number code