moved runAPI to its own file