Updated format function