most of the app's logic