example code from heroku.com