made proper randomization