randomize(L) waiting for testing; main has been shortened and improved