hook up app to run in browser; rename functions and add comments