rewrite toHex method