tidied up app.c