refactor to make it easier to specify format