Refactor to use the new API