put app.run() in if statement