Fix a bug in random_step