use struct app instead of global variables