get rid of echo and exit in API