using original code from paper as random number generator