thresh changed to uniform rand, working