Modified SQL to work with heroku