fixed bad toHex function