fix solve function and add more randomness