Added formatHex function