fix binary bug
optional debug print
add missing branch in while