fixed syntax errors; output of toBinary is a bit odd though