Replaced random() with the correct Math.random().