Refactors APIHandler:callAPI

Refactors and optimizes the APIHandler->callAPI … saves some loops and makes it less ugly.