randomization method fixed; delete function used instead of undef