fix incorrect logic in hex parsing