Fixed bug with using 'app' global variable