removed all instances of mt_rand for more security