rewrite app.py to utilise object instead of function