refactor res.format() with a little ocd