Replace rand()&2 with rand()%3

As rand()&2 never evaluates to 1