Refactored code to use AFNetworking API calls.