Try to make the app more readable by breaking up functions into smaller pieces and defining a single entry point

But, it's broken. I've encountered the problem which promises solve: the function which renders the results is being called before the results are returned.
Successfully use a promise to defer the rendering of data until the server response is received