could just put app in the function definition or use instance in the rest of the code...