Added documentation and changed random