Refactor to match new API