fixed code in the random algorithm by gwen