Added randomization and tested

Added randomization and tested. Tests were successful.