bug fix: using global random