remove direct calls to Math.random