This should work. Maybe problem that you generate random integer only 0 and 1, so its small amount of possibilities.