removed srand() instances before every call to rand. Otherwise, the resultant sequence is not guaranteed to be random, and in fact is very non-random on OS X