working api call. move stuff out of main