Changed example to use promises