added gray code, tricky one