Modified code to reflect the new API structure.