Fixed API calls, updated query