using random seed
loop corrected
docstrings added