Bug fix to unrandomization routine from sanfordsquires