Properly implemented format function.