grayCode with bug