Refactor to get a better API