Slightly changed the mystery code to match curand code