refactor send-api-command out
Refactor to use new send-api-command func
reformat