exporting app instance and making listening optional