Working version using random numbersr