factor out api from formatting