Fixed a bug in the way the API was called