changed random gen code