Refactored inline with latest API changes