Refactored node app file due to "app crashes" issue on heroku