random lib

resubmit of pull request