Minor refactor of res.format