added to_hex function