Fixed if statement and API calls.